<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8"><style type="text/css" media="screen">
    *{border:0;padding: 0;margin: 0;}
    body {width: 100%;height: 100%;overflow: auto;background:url(720.jpg)top center no-repeat; background-size:cover;}
    img {width: 100%;height: 100%;}
    #arrow{z-index: 2;position: absolute;top: 0;}
    #cnzz_stat_icon_1259952289{display:none;}
</style>
</head>
<body >
<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1260962050'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D1260962050' type='text/javascript'%3E%3C/script%3E"));</script>
	<script type="text/javascript">


    document.onkeydown=function(event){
             if(event.keyCode==4){                  
                  backs();
               }
              
          }


          function onKeyDown(event){
             if (event == 4) {
                backs();
              }
          }


		function backs(){
			 try{
              Android.onBackPressed();
            }catch(e){ 
            }  
		} 


		

		var nickname;
		var socket;
		if (!window.WebSocket) {
			window.WebSocket = window.MozWebSocket;
		}
		if (window.WebSocket) {
			socket = new WebSocket("ws://www.0x1000.com:8686/ws");
			
			socket.onmessage = function(event) {
				//var ta = document.getElementById('responseText');
			//	ta.value = ta.value + '\n' + ''+event.data;
				eventfilter(event.data);
			};
			socket.onopen = function(event) {
				var ta = document.getElementById('responseText');
				ta.value = "你已经进入神秘的酒店聊天室!";
			};
			socket.onclose = function(event) {
				var ta = document.getElementById('responseText');
				ta.value = ta.value + "\n 服务器死了，悲哀";
			};
		} else {
			alert("抱歉，出问题了，你真用不了这程序！");
		}

		function eventfilter(eventdata){
			//alert(eventdata);
			var t = eventdata.split("#");
			if(t[0]=='msg'){
				var msg = t[1] +'说:' + t[2];
				appendMsg(msg);
			}else if(t[0]=='sysmsg'){
				var msg = t[1];
				appendMsg(msg);
			}else if(t[0]=='nickerror'){
				alert(t[1]);
				document.getElementById("nameDiv").style.display="block";
			    document.getElementById("room").style.display="none";
			}else if(t[0]=='listcount'){
				document.getElementById("listcount").innerText = "当前在线："+t[1]+" 人";
			}
		}
		<!-- 普通文本-->
		function appendMsg(msg) {			
			var ta = document.getElementById('responseText');		
			ta.value = ta.value + '\n' +msg;
			ta.scrollTop = ta.scrollHeight;	
		} 

		/* 系统文本
		function appendsysMsg(msg) {			
			var ta = document.getElementById('responseText');	
			ta.value = ta.value + '\n' +msg;
			ta.style.color="red";
			ta.scrollTop = ta.scrollHeight;	
		} 
		*/
	

		<!-- 发送出口-->
		function sendx(message) {
			if (!window.WebSocket) {

				return false;
			}
			if (socket.readyState == WebSocket.OPEN) {				
				socket.send(message);
				return true;
				
			} else {
				alert("连接没有开启.");
				return false;
			}
		}
	
	

		function trim(str) {
			return str.replace(/(^\s+)|(\s+$)/g, "");
	}


	</script> 


<div id="room" style="display:block">
	<form onsubmit="return false;" width="100%">
		<center><h2 style="margin-top:5px">午夜聊天室</h2></center>		
		<p  style="width:70%;float:right;margin-right:10px;color:blue;font-size:14px;margin-top:10px"  id="listcount"> </p>
		<textarea id="responseText"   style="width:70%;float:right;margin-top:5px;margin-right:10px;margin-bottom:10px;height:700px;background:#ffe4e4 no-repeat right;" readonly="readonly"></textarea>
		<br> 
	
	<!-- 注释内容 
		<input type="button" onclick="javascript:document.getElementById('responseText').value=''" value="清空聊天记录">
		-->
	</form>
	<br> 
	<br>
	</div>
</body>
</html>
